
import { createStore } from 'vuex'
import createPersistedstate from 'vuex-persistedstate'

import user from './modules/user'
import cart from './modules/cart'
import category from './modules/category'

const store =  createStore({
  // state: {
  //   profile:{
  //     username:'游客',
  //     age:18
  //   }
  // },
  // mutations: {
  //   setProfile(state,payload) {
  //     console.log(state,payload)
  //     state.profile = payload
  //   }
  // },
  // actions: {
  // },
  // 模块化
  modules: {
    user,
    cart,
    category
  },
  // VueX 插件配置项
  plugins: [
    // 持久化存储插件
    createPersistedstate({
      key: 'erabbit-client-pc-store-65',
      paths: ['user', 'cart']
    })
  ]
})
export default store
